package com.chinatelecom.ifree.business.dao.order.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

import org.springframework.stereotype.Repository;

import com.chinatelecom.ifree.business.dao.order.FileDetailEntityDao;
import com.chinatelecom.ifree.business.domain.order.FileDetailEntity;

@Repository
public class FileDetailEntityDaoImpl extends BaseDaoSupport<FileDetailEntity> implements FileDetailEntityDao {
	@Override
	public void saveBatchFileDetail(FileDetailEntity[] entitys) throws Exception {
		sql = "INSERT INTO file_detail(BATCH_ID,CONTENT,STATUS,ERROR_MSG,REMARK) VALUE(?,?,?,?,?)";
		super.saveBatchEntity(entitys);
	}

	@Override
	public void saveFileDetail(FileDetailEntity entity) throws Exception {
		sql = "INSERT INTO file_detail(BATCH_ID,CONTENT,STATUS,ERROR_MSG,REMARK) VALUE(?,?,?,?,?)";
		super.saveEntity(entity);
	}
	@Override
	public FileDetailEntity executeSingleResultSet(ResultSet rs) throws Exception {
		return null;
	}

	@Override
	public void executeSql(PreparedStatement state, FileDetailEntity entity) throws Exception {
		state.setString(1, entity.getBatchId());
		state.setString(2, entity.getContent());
		state.setInt(3, entity.getStatus());
		state.setString(4, entity.getErrorMsg());
		state.setString(5, entity.getRemark());
	}

	@Override
	public void executeBatchSql(PreparedStatement state, FileDetailEntity[] entitys) throws Exception {
		for (FileDetailEntity entity : entitys) {
			state.setString(1, entity.getBatchId());
			state.setString(2, entity.getContent());
			state.setInt(3, entity.getStatus());
			state.setString(4, entity.getErrorMsg());
			state.setString(5, entity.getRemark());
			state.addBatch();
		}
	}

}
